package main.com.dhj.test02

object test02 {

    def main(args: Array[String]): Unit = {
        val domainName = "www.example.com"
        def getURL = urlBuilder(ssl = true, domainName)

        val endpoint = "users"
        val query = "id=1"
        val url = getURL(endpoint, query);
        println(url);

    }

    // 等价于 def urlBuilder(ssl: Boolean, domainName: String) : function
    // 冒号后面的都是返回的function的内容
    def urlBuilder(ssl: Boolean, domainName: String) : (String, String) => String ={
        val schema = if(ssl) "https://" else "http://";
        (endpoint: String, query: String) => s"$schema$domainName/$endpoint?$query"
    }

}

